// 转二进制
export function binary (num1, Bits) {
    let num = num1
    let resArry = []
    let xresArry = []
    let i = 0
    // 除2取余
    for (; num > 0;) {
      resArry.push(num % 2)
      num = parseInt((num / 2).toString())
      i++
    }
    // 倒序排列
    for (let j = i - 1; j >= 0; j--) {
      xresArry.push(resArry[j])
    }
    // 报错
    if (Bits && Bits < xresArry.length) {
      console.log('控制位小于转换位数')
    }
    // 补0操作
    if (Bits) {
      for (let r = xresArry.length, bit = Bits; r < bit; r++) {
        xresArry.unshift('0')
      }
    }
    return xresArry.join().replace(/,/g, '')
  }
  
// 四舍五入
export function round(number, precision) {
    return Math.round(Number((+number + 'e' + precision))) / Math.pow(10, precision);
    //same as:
    //return Number(Math.round(+number + 'e' + precision) + 'e-' + precision);
  }